package com.itheima.mobile.mapper;

import com.itheima.mobile.pojo.Order;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;

import java.util.Date;

public interface OrderDao {
    Order getOrderByPhoneAndDateAndSetmealId(@Param("phone") String phone, @Param("date") String date, @Param("setmealId") String setmealId);

    @Insert("insert into t_order values(null,#{memberId},#{orderDate},#{orderType},#{orderStatus},#{setmealId})")
    @SelectKey(statement = "select last_insert_id() from dual", before = false,
            resultType = Integer.class, keyColumn = "id", keyProperty = "id"
    )
    int save(Order order);

    @Select("select * from t_order where id = #{id}")
    Order findById(String id);
}
